package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.entidades.Laboratorio;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.auth_annotations.Administrador;
import br.com.caelum.vraptor.dao.GenericDAO;

@Controller
public class LaboratorioController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Laboratorio> dao;
	
	public void add(){
		
	}
	@Administrador
	public List<Laboratorio> list(){
        return dao.find();
	}
	@Administrador
	public void save(Laboratorio laboratorio){
        dao.save(laboratorio);
        result.redirectTo(this).list();
	}	
	@Administrador
	public Laboratorio edit(int id){
    return dao.find(id);
	}
	@Administrador
	public void delete(int id){
    Laboratorio laboratorio = new Laboratorio();
    laboratorio.setId(id);
    dao.delete(laboratorio);
    result.redirectTo(this).list();
	}
	
}
